<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>async练习题</title>
</head>

<body>

</body>

</html>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
<script>

    {
        //封装方法 
        // function getdate(url) {
        //     return Promise.resolve(
        //         $.ajax({
        //             url: url,
        //             success(data) {
        //                 console.log("data===>", data);
        //             }
        //         })
        //     )
          
        // }

        let getdate = (url) => Promise.resolve(
            $.ajax({
                url: url,
                success(data) {
                    console.log("data===>", data);
                }
            })
        )

        let as = () => Promise.resolve(
            $.ajax({
                url: "../data/aa.txt"
            })
        )
        async function lc() {
            let date = await as()
            lclist = JSON.parse(date)

            if (lclist.type === "marger") {
                let indexInfo = getdate("../data/bbb.txt");
                console.log("展示所有的用户信息===>", indexInfo)
            } else {

                let normaluser = await getdate("../data/ddd.txt");
                console.log("展示当前的用户信息===>", normaluser)
            }
        }
        lc()


    }


</script>